import request from '/@/utils/request'

export function api(tablename: any, functions: any, method: any, params: any) {
  params.model = tablename
  const res = request({
    url: `/base/${functions}`,
    method: method ? method : 'get',
    params,
  })
  console.log(`api_${tablename}_${functions}`, res)
  return res
}

export function api_getLast(tablename: any, params: any) {
  params.model = tablename
  const res = request({
    url: `/base/getLast`,
    method: 'get',
    params,
  })
  // console.log('api_getall', res)
  return res
}

export function api_saas_detail(tablename: any, params: any) {
  params.model = tablename
  const res = request({
    url: `/base/saas_detail`,
    method: 'get',
    params,
  })
  console.log('api_saas_detail', res)
  return res
}

export function api_getall(tablename: any, params: any) {
  params.model = tablename
  const res = request({
    url: `/base/getall`,
    method: 'get',
    params,
  })
  // console.log('api_getall', res)
  return res
}

export function api_datalist(tablename: any, params: any) {
  params.model = tablename
  const res = request({
    url: `/base/datalist`,
    method: 'get',
    params,
  })
  console.log('api_datalist', res)
  return res
}

//查询回收站
export function api_recycle(tablename: any, params: any) {
  params.model = tablename
  const res = request({
    url: `/base/datalist_recycle`,
    method: 'get',
    params,
  })
  return res
}
//恢复数据
export function api_recovery(tablename: any, params: any) {
  params.model = tablename
  const res = request({
    url: `/base/recovery`,
    method: 'get',
    params,
  })
  return res
}
//彻底删除
export function api_com_del(tablename: any, params: any) {
  params.model = tablename
  const res = request({
    url: `/base/com_del`,
    method: 'get',
    params,
  })
  return res
}
//批量恢复
export function api_recoveryChecked(tablename: any, params: any) {
  params.model = tablename
  const res = request({
    url: `/base/recoveryChecked`,
    method: 'post',
    params,
  })
  return res
}

//批量彻底删除
export function api_com_delChecked(tablename: any, params: any) {
  params.model = tablename
  const res = request({
    url: `/base/com_delChecked`,
    method: 'post',
    params,
  })
  return res
}

export function api_save(tablename: any, data: any) {
  data.model = tablename
  const res = request({
    url: `/base/save`,
    method: 'post',
    data,
  })
  console.log(res)
  return res
}
export function api_del(tablename: any, params: any) {
  params.model = tablename
  const res = request({
    url: `/base/del`,
    method: 'post',
    params,
  })
  return res
}
export function api_delChecked(tablename: any, params: any) {
  console.log(params)
  params.model = tablename
  const res = request({
    url: `/base/delChecked`,
    method: 'post',
    params,
  })
  return res
}
export function api_detail(tablename: any, params: any) {
  params.model = tablename
  const res = request({
    url: `/base/detail`,
    method: 'post',
    params,
  })
  return res
}

export function api_changeStatus(tablename: any, params: any) {
  params.model = tablename
  return request({
    url: `/base/changeStatus`,
    method: 'post',
    params,
  })
}

export function api_exportsChecked(tablename: any, params: any) {
  params.model = tablename
  const res = request({
    url: `/base/exportsChecked`,
    method: 'post',
    params,
  })
  return res
}
export function api_exports(tablename: any, params: any) {
  params.model = tablename
  const res = request({
    url: `/base/exports`,
    method: 'post',
    params,
  })
  return res
}
